import axios from './axios'
import qs from 'qs'
import { appUrl } from '@/config/config'

//获取教师授课年级班级
export const getTeacherGradeClases = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/bdc/api/app/teacher/${params}/gradeClases`,
        method: 'get',
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


//获取班级学生列表（含学生点评数据）
export const getStudentsAndReviewList = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/classroom/schoolClass/studentsAndReviewList`,
        method: 'get',
        params
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


//学生点评类别 --- 获取列表
export const getStudentsReviewType = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/studentcomments/reviewType`,
        method: 'get',
        params
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}
    
//学生点评类别 --- 批量删除
export const delReviewTypeList = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: `${appUrl}/school/api/studentcomments/reviewType/list`,
            method: 'delete',
            params,
            paramsSerializer: function(params) {
                return qs.stringify(params, {arrayFormat: 'repeat'})
            }
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


//添加点评
export const postStudentReview = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/studentcomments/studentReview`,
        method: 'post',
        data:params
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

//创建点评类别
export const postReviewType = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/studentcomments/reviewType`,
        method: 'post',
        data:params
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

//更新点评类别
export const putReviewType = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/studentcomments/reviewType?id=${params.id}`,
        method: 'put',
        data:params.data
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


//获取默认图标列表
export const getIconList = () => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/studentcomments/studentCommentImages`,
        method: 'get',
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


//学生档案
export const getStudentArchives = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/studentcomments/studentReview/studentArchives`,
        method: 'get',
        params
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

//班级点评明细列表（移动端-教师-班级得分明细）
export const getClassStudentInfoList = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/studentcomments/studentReview/classStudentList`,
        method: 'get',
        params
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

//学生点评明细列表
export const getStudentInfoList = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/studentcomments/studentReview/studentList`,
        method: 'get',
        params
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}


//删除点评
export const delStudentReview = (params) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/school/api/studentcomments/studentReview`,
        method: 'delete',
        params,
        paramsSerializer: function(params) {
            return qs.stringify(params, {arrayFormat: 'repeat'})
        }
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}

//获取学生
export const getStudentInfo = (id) => {
    return new Promise((resolve, reject) => {
        axios({
        url: `${appUrl}/bdc/api/app/student/${id}`,
        method: 'get',
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    })
}